#include <iostream>
#include <vector>
#include <string>

// 定义一个装饰器类，用于为vector添加日志记录功能
template <typename T>
class LoggingVector {
private:
    std::vector<T> data;
public:
    // 向容器中添加元素，并记录日志
    void push_back(const T& element) {
        std::cout << "add element to vector:" << element << std::endl;
        data.push_back(element);
    }

    // 遍历容器并输出元素，同时记录日志
    void print() const {
        std::cout << "the vector contains:";
        for (const T& element : data) {
            std::cout << element << " ";
        }
        std::cout << std::endl;
    }
};

int main() {

    // 创建一个存储整数的vector容器
    std::vector<int> numbers;

    // 向容器中添加元素
    numbers.push_back(1);
    numbers.push_back(2);
    numbers.push_back(3);

    // 遍历容器并输出元素
    std::cout << "numbers:";
    for (int num : numbers) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // 获取容器大小
    std::cout << "vector size:" << numbers.size() << std::endl;

    LoggingVector<int> loggingNumbers;

    loggingNumbers.push_back(10);
    loggingNumbers.push_back(20);
    loggingNumbers.push_back(30);

    loggingNumbers.print();

    return 0;
}